package com.xs.project.controller;

import com.xs.project.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/file")
@Api(tags = "文件管理")
public class FileController {
    @Resource
    private FileService fileService;
    @PostMapping("/upload")
    @ApiOperation(value = "文件上传", notes = "文件上传")
    public String handleFileUpload(@RequestParam("file") MultipartFile file) {
        return fileService.uploadFile(file);
    }
    @GetMapping("/down")
    @ApiOperation(value = "文件下载", notes = "文件下载")
    public void handleFileDown(String fileName, String path, HttpServletResponse response) {
        fileService.downloadFile(fileName,path,response);
    }
}
